import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class TT(QTableWidget):
    def __init__(self):
        super(TT, self).__init__()

        self.setRowCount(5)
        self.setColumnCount(6)
        self.setVerticalHeaderLabels(['r1','r2','r3','r4','r5'])
        self.setHorizontalHeaderLabels(['c1','c2','c3','c4','c5','c6'])
        self.init_items()
        self.text()
    def init_items(self):
        for r in range(self.rowCount()):
            for c in range(self.columnCount()):
                item=QTableWidgetItem()
                item.setText('')
                self.setItem(r,c,item)


    def text(self):


        v_list = []
        for v in range(self.rowCount()):
            v_item = self.verticalHeaderItem(v)
            text = v_item.text()
            v_list.append(text)

        h_list = ['']
        for h in range(self.columnCount()):
            h_item = self.horizontalHeaderItem(h)
            text = h_item.text()
            h_list.append(text)
        all_row_data = [h_list]

        for r in range(self.rowCount()):
            per_row_list=[v_list[r]]
            for c in range(self.columnCount()):
                c_item=self.item(r,c)
                # print(r,c)

                text=c_item.text()
                per_row_list.append(text)

            all_row_data.append(per_row_list)
        print(all_row_data)


if __name__ == '__main__':
    app=QApplication(sys.argv)
    t=TT()
    t.show()
    sys.exit(app.exec_())